{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# H-Index（H指数）\n",
    "\n",
    "![Logo](images/Day74-1.png)\n",
    "\n",
    "[@mjd507](https://github.com/mjd507) | [Wechat Channel（微信公众号）](https://mp.weixin.qq.com/s/ocmESsXT9j2zCQPmovoeYw)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The *h-index* is a metric that attempts to measure the productivity and citation impact of the publication of a scholar. The definition of the *h-index* is if a scholar has at least $h$ or their paperss cited $h$ times.\n",
    "\n",
    "Given a list of publications of the number of citations a scholar has, find their *h-index*."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "*h指数*是一个用于量化学者生产力与出版物引用数量的指数。*h指数*的定义是一名学者有$h$篇论文至少被引用了$h$次。\n",
    "\n",
    "给定一个表示论文引用次数的列表，确定其*h指数*。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Starting Point（初始模板）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "def hIndex(publications: list) -> int:\n",
    "    # Sort the list descending.\n",
    "    publications.sort(reverse=True)\n",
    "    \n",
    "    for i in range(len(publications)):\n",
    "        if publications[i] <= i:\n",
    "            break\n",
    "    return i"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Test Cases（测试用例）\n",
    "\n",
    "```python\n",
    "Input: [3, 5, 0, 1, 3]\n",
    "Output: 3\n",
    "```\n",
    "\n",
    "There are $3$ publications with $3$ or more citations, hence the *h-index* is $3$.\n",
    "\n",
    "有3篇论文被引用了至少3次，所以*h指数*为3。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hIndex([5, 3, 3, 1, 0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hIndex([3, 5, 0, 1, 3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hIndex([4, 4, 7, 9, 2])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
